<template>
	<view class="main">
		<view style="margin-top:200rpx;margin-left:15rpx;">
			<text class="title">欢迎登录</text>
		</view>
		
		<view style="margin-top:90rpx; padding: 20px;" >
			<u-button :ripple="true" type="success" @click="mpWechatLogin" shape="circle" ><u-icon  name="weixin-fill" size="40" style="margin-right:10rpx;"></u-icon> 微信授权登录</u-button>
		</view>
		
		
		
		<view class="" style="margin-top:0rpx; padding: 20px;">
			<u-button  @click="psw_login">账号密码登录</u-button>
		</view>
	
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				code:''
			};
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			uni.login({
				provider:'weixin',
				success: (res) => {
					this.code = res.code
					uniCloud.callFunction({
						name:'weixinLogin',
						data:{
							code:this.code
						},
						success: (res) => {
							console.log(res)
						}
					})
				},
				
			})
			// #endif
		},
		methods:{
			init(options){
				if (!options) options = that.options;
				console.log("init: ",options);
				
			},
			psw_login(){
				uni.navigateTo({
					url:'psw-login/psw-login'
				})
			},
			mpWechatLogin(e){
				// 微信登录网页授权
				
				// #ifdef H5
				
				
				var u = navigator.appVersion;
				var ua = window.navigator.userAgent.toLowerCase();
				console.log(u)
				console.log(ua)
				
				// return
				
				
				let APPID = 'wx87f986a3a69bdb18'
				let REDIRECT_URI = encodeURIComponent('https://zixun.pyplwf.cn')
				let SCOPE = 'snsapi_userinfo'
				location.href=`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APPID}&redirect_uri=${REDIRECT_URI}&response_type=code&scope=${SCOPE}&state=STATE#wechat_redirect `
				// #endif
				
				return
				// let userInfo = e.detail.userInfo;
				
			
			},
			work_login(){
				getApp().globalData.loginType = 'work_login'
				uni.navigateTo({
					url:'../psw-login/login/login'
				})
			}
		}
	}
</script>

<style lang="scss">
	.main{
		padding:20rpx 20rpx;
	}
	.title{
		font-size:48rpx;
		padding-bottom:15rpx;
		border-bottom: 5rpx solid #bbb;
	}
	.imgZhixun{
		position: absolute;
		bottom: 80rpx;
		left: 50%;
		
	}
	.img {
		transform: translateX(-50%);
	}
	.img_text {
		transform: translateX(-50%);
	}
	
</style>
